function StringBuilder() {

	var _result = '';
	
	this.Append = function(s) {
		_result = _result.concat(s);
	}
	
	this.AppendLine = function(s) {
		_result = _result.concat(s,'\n');
	}
	
	this.AppendFormat = function(s) {
		_result = _result.concat(String.Format(arguments)); 
	}
	
	this.Length = function() {
		return _result.length;
	}
	
	this.ToString = function() {
		return _result;
	}
}

String.Empty = '';

String.Format = function() {
	var args = null;
	var indexModifier = 0;
	var result = null;
	
	if(arguments[0] == '[object Arguments]') {
		args = arguments[0];
		result = args[0];
	} else if (arguments[1] == '[object Arguments]') {
		args = arguments[1];
		indexModifier = 1;
		result = arguments[0];
	} else {
		args = arguments;
		result = args[0];
	}
	
	for(var i = 1; i < args.length + indexModifier; i++) {
		var formatItemRegExp = 
			new RegExp('\{' + (i - 1) + '((\\,\\d*)|()|(:[cC]))\\}');
			
		var formatItem = 
			formatItemRegExp.exec(result)[0];
		
		var formatter = 
			_getStringFormatter(formatItem);
		
		result = formatter(result, formatItem, args[i - indexModifier]);
	}
	
	return result;	
	
	function _getStringFormatter(f) { 
		var standard = new RegExp('\\{\\d*\\}');
		var alignment = new RegExp('\\{\\d*\\,\\d*\\}');
		var currency = new RegExp('\\{\\d*:[cC]\\}');
		
		if(standard.test(f)) {
			return function(r,f,a) { 
				return r.replace(f,a); 
			}
		} else if(alignment.test(f)) {
			return function(r,f,a) { 
				var alignmentValuePattern = new RegExp('\\,\\d*(?=\\})');
				var alignmentValue = alignmentValuePattern.exec(f)[0].replace(',','');
				
				var amountToPad = alignmentValue - a.length;
				
				if(amountToPad > 0) {
					for(var i = 0; i < amountToPad; i++) {
						a += ' ';
					}
				}

				return r.replace(f,a); 
			}
		} else if(currency.test(f)) {
			return function(r,f,a) {
				if(isNaN(a)) {
					throw 'Cannot format a value as currency unless it\'s number.';
				} else {
					var formattedCurrency = '$' + (Math.round(a * 100) / 100);
					
					return r.replace(f,formattedCurrency);					
				}
			}
		} else {
			throw 'The format item provided is not supported.';
		}	
	}
}

String.prototype.Format = function() {
	return String.Format(this.valueOf(), arguments);
}